package cn.itcast.demo03;

/*
1-n的和，用递归
 */
public class Demo01Add {
    public static void main(String[] args) {
        int add = sum(100);
        System.out.println(add);
    }

    private static int sum(int n) {
        if (n == 1) {
            return 1;
        }
        return n + sum(n - 1);
    }
}
